const fs = require('fs');
const Watcher = require('./watcher');

const watchDir = './chapter03/event/watch';
const processedDir = './chapter03/event/done';

const watcher = new Watcher(watchDir, processedDir);

watcher.on('process', function (file) {
  const watchFile = `${this.watchDir}/${file}`;
  const processedFile = `${this.processedDir}/${file.toLowerCase()}`;

  fs.rename(watchFile, processedFile, function (err) {
    if (err) {
      throw err;
    }
  });
});

watcher.start();
